package com.junmo.fanbizhidemo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.junmo.fanbizhidemo.R;
import com.junmo.fanbizhidemo.view.OverlappingImageView;

/**
 * Created by huruihua on 2017/8/29.
 */

public class ImageGGAdapter extends BaseRecyclerAdapter<String> {
    private Context mContext;
    private int ITEM = 1;
    private int ADVERTISING = 2;
    private ViewGroup parent;
    @Override
    public RecyclerView.ViewHolder onCreate(ViewGroup parent, int viewType) {
//        mContext = parent.getContext();
//        return new ImageViewHode(LayoutInflater.from(mContext).inflate(R.layout.item_gg_layout, parent, false));
        this.parent = parent;
        View view = null;
        if (viewType == ITEM) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_test, parent, false);
        } else if (viewType == ADVERTISING) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gg_layout, parent, false);
        }
        return new ViewHolder(view);
    }

    @Override
    public void onBind(RecyclerView.ViewHolder viewHolder, int realPosition, String data) {
        if (getItemViewType(realPosition) == ADVERTISING) {
            ((ViewHolder)viewHolder).view.setRecyclerView(parent);
        }
    }

    class ViewHolder extends Holder {

        public OverlappingImageView view;

        public ViewHolder(View itemView) {
            super(itemView);
            view = (OverlappingImageView) itemView.findViewById(R.id.image);
        }
    }

}
